// ==UserScript==
// @name         去页面广告
// @namespace    http://tampermonkey.net/
// @version      2024-06-07
// @description  try to take over the world!
// @author       You
// @match        http://*/*
// @match        https://*/*
// @icon         http://wuweijun.fun/favicon.ico
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  // 通过隐藏的方式去掉广告
  var data = [
      { hostname: 'www.uuks5.com', tag: '.adsbygoogle.adsbygoogle-noablate' },
      { hostname: 'www.27k.net', tag: '.adsbygoogle.adsbygoogle-noablate' },
      { hostname: '', tag: '.adsbygoogle.adsbygoogle-noablate' },
      { hostname: 'yunxuange.la', tag: '#reader-m-fix div[id^="top_"]', interval:true },
      { hostname: '', tag: '.remind', interval:true },
      { hostname: '', tag: '#yhp', interval:true },
      { hostname: 'm.libahao.com', tag: '.navbar', interval:true },
  ]
  let t1 = setInterval(() => {
      for (let index = 0; index < data.length; index++) {
          const element = data[index];
          if (location.href.includes(element.hostname)) {
              try {
                  document.querySelectorAll(element.tag).forEach((docItem) => {
                      docItem.setAttribute('style', 'display: none !important;')
                  })
                  element.interval || clearInterval(t1)
              } catch (error) {
                  console.log(error)
                  alert('清除广告失败', element.hostname, element.tag)
              }
          }
      }
  }, 1000);



  // 通过点击的方式去掉广告
  var data2 = [
      { hostname: 'www.iqiyi.com', tag: '.pause-max-close-btn', interval:true },
      { hostname: 'www.iqiyi.com', tag: '.overlay-close', interval:true },
  ]
  let t2 = setInterval(() => {
      for (let index = 0; index < data2.length; index++) {
          const element = data2[index];
          if (location.href.includes(element.hostname)) {
              try {
                  document.querySelectorAll(element.tag).forEach((docItem) => {
                      docItem.click()
                  })
                  element.interval || clearInterval(t2)
              } catch (error) {
                  alert('清楚广告失败', element.hostname, element.tag)
              }
          }
      }
  }, 1000);


  // Your code here...
})();